package com.ctshk.rpc.finance.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.finance.dto.advance.AdvancePaymentApplyDTO;
import com.ctshk.rpc.finance.entity.FinanceAdvancePaymentApply;
import org.apache.ibatis.annotations.*;

/**
 * <p>
 * 财务预收款申请表 Mapper 接口
 * </p>
 *
 * @author 谢涛
 * @since 2021-03-23
 */
public interface FinanceAdvancePaymentApplyMapper extends BaseMapper<FinanceAdvancePaymentApply> {

    /**
     * 申请预收款详情
     * @param applyId
     * @return
     */
    @Select("SELECT a.money_amount,a.unavailable_amount,a.available_amount,a.currency,a.exchange_rate,a.payment_method_name,a.collection_time,a.explains,a.approval_status,a.approval_id,a.file_json,a.create_id,\n" +
            "b.supplier_name,b.supplier_contacts,b.supplier_telephone,b.supplier_email,b.supplier_address,b.supplier_bank_card,b.supplier_bank_name\n" +
            "FROM t_finance_advance_payment_apply a\n" +
            "LEFT JOIN t_finance_advance_payment b ON a.advance_payment_id = b.id\n" +
            "WHERE a.is_deleted = 0 AND a.id = #{id} OR a.approval_id = #{id}")
    AdvancePaymentApplyDTO queryDetail(@Param("id") Long applyId);
}
